//
//  ONObjectColumn.m
//  Volatix
//
//  Created by Familly on 6/13/14.
//  Copyright (c) 2014 Familly. All rights reserved.
//

#import "ONObjectColumn.h"
@interface ONObjectRealTime ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end
@implementation ONObjectColumn
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}
- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    BOOL isDictionary=NO;
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
        /// bool
        isDictionary=YES;
        self.nameColumn=[self objectOrNilForKey:@"columnName" fromDictionary:dict];
        self.screenName=[self objectOrNilForKey:@"screenName" fromDictionary:dict];
        
        
    }
    
    return (isDictionary)?self:nil;
    
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}

@end
